/**
 * 
 */
package com.jiang.factory;

import java.lang.reflect.Constructor;
import java.sql.Connection;


/**
 * @author Administrator
 *
 */
public class DaoFactory {
	
	
	private DaoFactory(){
		
	}
	
	/**
	 * @工厂类获取dao实现类
	 * @param clazz
	 * @return
	 */
	public static <T>  T  getInstance(Connection conn, Class<T> clazz){
		
		T t = null;
		try {
			//注意下面只能用父类型Connection，而conn.getClass()是Connection的子类jdbc4Connection，没有这个子类型的构造函数,只有父类型的
			Constructor<T> constructor = clazz.getConstructor(Connection.class);
			t = constructor.newInstance(conn);
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return t;
	}
	

}
